package de.hatraco.funderberg.blackjack.model;

import java.util.ArrayList;
import java.util.List;

public class Deck {
	
	private static Deck instance = new Deck();

	public static Deck getInstance() {
		if(instance == null) {
			instance = new Deck();
		}
		return instance;
	}
	
	private List<Card> deck = new ArrayList<Card>();
			
	private Deck() {
		
		//definiert ein Array mit den Kartenfarben Karo (0) bis Kreuz (3)
		String colors [] = {"Karo ", "Herz ", "Pik ", "Kreuz "};
		
		//definiert ein Array mit den Kartenarten "2" (0) bis "Ass" (12)
		String kinds [] = {"2", "3", "4", "5", "6", "7", "8", "9", "10", "B", "D", "K", "A"};
		
		//for-Schleifen, die die Karten des Decks generieren
		for (int a = 0; a <=5; a++) {		
			for (int b = 0; b < colors.length; b++) {
				for (int c = 0; c < kinds.length; c++) {
					if (c <= 8) {	
						Card k = new Card(colors[b], kinds[c], (c+2), ((a*52 + (b*13) + c)));
						deck.add(k);
					}
					else {
						if (c <= 11) {
							Card k = new Card(colors[b], kinds[c], 10, ((a*52 + (b*13) + c)));
							deck.add(k);
						}
						else {
							Card k = new Card(colors[b], kinds[c], 11, ((a*52 + (b*13) + c)));
							deck.add(k);
						}
					}		
				}
			}
		}	
	}

	public List<Card> getDeck() {
		return deck;
	}

	public void setDeck(List<Card> deck) {
		this.deck = deck;
	}
}